<!DOCTYPE html>
<html>
<head>
    <title>工装清单</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.toolsCode" @on-enter="query" placeholder="工装编码"></i-input>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="名称"></i-input>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>

<script>
    $(function () {
        var queryUrl = '../toolslist/list?progress=5';
        // 拼接管控方式条件
        var controlWay = getQueryString('controlWay');
        if (controlWay) {
            queryUrl += '&controlWay=' + controlWay;
        }
        // 获取拼接产线
        var productLine = getQueryString('productLine');
        if (productLine) {
            queryUrl += '&productLine=' + productLine;
        }
        $("#jqGrid").Grid({
            url: queryUrl,
            rownumWidth: 35,
            colModel: [
                {label: '工装编码', name: 'toolsCode', index: 'TOOLS_CODE', width: 60},
                {label: '名称', name: 'name', index: 'NAME', width: 80},
                {label: '图号', name: 'mapNo', index: 'MAP_NO'},
                {label: '自制图号', name: 'createNo', index: 'CREATE_NO', width: 80},
                {label: '型号规格', name: 'type', index: 'TYPE', width: 80},
                {label: '适用机型', name: 'applicableModel', index: 'APPLICABLE_MODEL', width: 80},
                {label: '装机量', name: 'capacity', index: 'CAPACITY', width: 50},
                {label: '产线/工序', name: 'useProcedure', index: 'USE_PROCEDURE', width: 120,
                    formatter: function (value, col, row) {
                        var desc = row.productLineName;
                        if(row.useProcedure && row.useProcedure !== 'null'){
                            desc += ' ' + row.useProcedure;
                        }
                        return desc;
                    }
                },
                {
                    label: '是否易损件', name: 'isVulnerable', index: 'IS_VULNERABLE', width: 80, formatter: function (value) {
                        return value === 0 ?
                            '<span class="label label-danger">否</span>' :
                            '<span class="label label-success">是</span>';
                    }
                },
                {label: '工装类别', name: 'typeName', index: 'TOOLS_TYPE', width: 60},
                {label: '管控方式', name: 'controlWayName', index: 'CONTROL_WAY', width: 60},
                {name: 'productLine',hidden:true},
                {name: 'stockNum',hidden:true},
                {name: 'transitNum',hidden:true},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true}
            ]
        });
    });
    var vm = new Vue({
        el: '#rrapp',
        data: {
            q: {
                name: '', // 名称
                toolsCode:'', // 工装编码
                productLineIds: '',
            }
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function () {
                vm.q = {
                    name: '',
                    productLineIds: '',
                    toolsCode:''
                };
                vm.reload();
            }
        }
    });
    var getTools = function () {
        let result = getSelectedRowData("#jqGrid");
        if(!result){
            return;
        }
        return result;
    }
    var getToolsList = function () {
        let ids = getSelectedRows("#jqGrid");
        if (ids == null) {
            return;
        }
        return ids;
    }
</script>
</body>
</html>
